package com.dxy.df.utils;

import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * @author wangsheng@dxy.cn
 * @date 2019-07-11
 **/
@Component
public class LogUtils {

    private static final Logger LOGGER = LoggerFactory.getLogger(LogUtils.class);

    public void printRequestLog(String response) {
        HttpServletRequest request = WebUtil.getHttpServletRequest();
        String requestUri = request.getRequestURI();
        String requestInfo = "";
        String parameterMap =  JSONObject.toJSONString(request.getParameterMap());
        try {
            LOGGER.info(" <--- uri:{}; parameterMap:{} ; argsJson:{} .\t   ---> ,url:{}, result: {}",
                    requestUri,parameterMap,requestInfo, requestUri, response);
        } catch (Exception e) {
            LOGGER.error("打印日志APiFilter出错,{}",e.getMessage());
        }
    }




}
